using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Data {
    
    public string sceneToSave;

    /// <summary>
    ///     角色的坐标位置（玩家、敌人）
    /// </summary>
    /// <typeparam name="string"></typeparam>
    /// <typeparam name="Vector3"></typeparam>
    /// <returns></returns>
    public Dictionary<string, SerializeVector3> characterPosDict = new Dictionary<string, SerializeVector3>();
    /// <summary>
    ///     角色的血量、能量值
    /// </summary>
    /// <typeparam name="string"></typeparam>
    /// <typeparam name="float"></typeparam>
    /// <returns></returns>
    public Dictionary<string, float> floatSavedData = new Dictionary<string, float>();

    public void SaveGameScene(GameSceneSO savedScene) {
        sceneToSave = JsonUtility.ToJson(savedScene);
        Debug.Log(sceneToSave);
    }

    public GameSceneSO GetSavedScene() {
        var newScene = ScriptableObject.CreateInstance<GameSceneSO>();
        JsonUtility.FromJsonOverwrite(sceneToSave, newScene);
        
        return newScene;
    }

}

public class SerializeVector3 {

    public float x, y, z;
    
    public SerializeVector3(Vector3 pos) {
        this.x = pos.x;
        this.y = pos.y;
        this.z = pos.z;
    }

    public Vector3 ToVector3() {
        return new Vector3(x, y, z);
    }

}